home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Found / FWStream / Include / FWArOper.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-08  |  3.1 KB  |  94 lines  |  [TEXT/MPS ]

  1. #ifndef FWAROPER_H
  2. #define FWAROPER_H
  3. //========================================================================================
  4. //
  5. //    File:                FWArOper.h
  6. //    Release Version:    $ 1.0d11 $
  7. //
  8. //    Copyright:    (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWARDYNA_H
  13. #include "FWArDyna.h"
  14. #endif
  15.  
  16. #ifndef SOM_SOMObject_xh
  17. //MOVE THIS INCLUDE AND THE DEFINITION OF FW_SomCast to a .cpp file
  18. #include <somobj.xh>
  19. #endif
  20.  
  21. #if FW_LIB_EXPORT_PRAGMAS
  22. #pragma lib_export on
  23. #endif
  24.  
  25. //----------------------------------------------------------------------------------------
  26. // FW_READ_DYNAMIC_OBJECT
  27. //
  28. // Global function for reading from a readableStream. The type 'className'
  29. // must be a dynamic class or a compile-time error will occur.
  30. //----------------------------------------------------------------------------------------
  31.  
  32. #define FW_READ_DYNAMIC_OBJECT(archive, object, className) \
  33.     { \
  34.         className** _temp_ = object;    \
  35.         FW_CDynamicArchiver::InputObject(archive, (void *&)(*_temp_)); \
  36.         *(object) = FW_DYNAMIC_CAST(className, *_temp_); \
  37.     }
  38.  
  39.  
  40.  
  41. //----------------------------------------------------------------------------------------
  42. // FW_WRITE_DYNAMIC_OBJECT
  43. //
  44. // Global function for writing to a writableStream. The type 'className' must
  45. // must be a dynamic class or a compile-time error will occur.
  46. //----------------------------------------------------------------------------------------
  47.  
  48. #define FW_WRITE_DYNAMIC_OBJECT(archive, object, className) \
  49.     { \
  50.         const className* _temp_ = object;    \
  51.         FW_CDynamicArchiver::OutputObject(archive, _temp_, FW_CLASSNAME_FROM_POINTER(_temp_)); \
  52.     }
  53.  
  54. //----------------------------------------------------------------------------------------
  55. // FW_READ_DYNAMIC_SOM_OBJECT
  56. //
  57. // Global function for reading from a readableStream. The type 'className'
  58. // must be a dynamic class or a compile-time error will occur.
  59. //----------------------------------------------------------------------------------------
  60.  
  61. inline SOMObject* FW_SomCast( SOMObject *object, SOMClass *className )
  62. {
  63.     FW_ASSERT(somIsObj(object));
  64.     FW_ASSERT(somIsObj(className));
  65.     return object->somIsA(className) ? object : 0;
  66. }
  67.  
  68. #define FW_READ_DYNAMIC_SOM_OBJECT(archive, object, className) \
  69.     { \
  70.         className** _temp_ = object;    \
  71.         FW_CDynamicArchiver::InputObject(archive, (void *&)(*_temp_)); \
  72.         *(object) = (className*)FW_SomCast(*_temp_,className##ClassData.classObject); \
  73.     }
  74.  
  75.  
  76. //----------------------------------------------------------------------------------------
  77. // FW_WRITE_DYNAMIC_SOM_OBJECT
  78. //
  79. // Global template function for writing to a writableStream. The type 'className' must
  80. // must be a dynamic class or a compile-time error will occur.
  81. //----------------------------------------------------------------------------------------
  82.  
  83. #define FW_WRITE_DYNAMIC_SOM_OBJECT(archive, object, className) \
  84.     { \
  85.         className* _temp_ = object;    \
  86.         FW_CDynamicArchiver::OutputObject(archive, _temp_, _temp_->somGetClassName()); \
  87.     }
  88.  
  89. #if FW_LIB_EXPORT_PRAGMAS
  90. #pragma lib_export off
  91. #endif
  92.  
  93. #endif
  94.